package com.wz.wzbubbleai.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.wz.wzbubbleai.activity.MainActivity;
import com.wz.wzbubbleai.service.FloatWindowService;
import com.wz.wzbubbleai.utils.LogUtil;

/**
 * Created by wangbin on 18-1-9.
 */

public class VoiceBroacastReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
        //startActivity(context);
        startService(context);
    }

    /**
     * 启动主activity
     * @param context
     */
    private void startActivity(Context context){
        Intent voiceIntent = new Intent(context, MainActivity.class);
        voiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        context.startActivity(voiceIntent);
    }

    /**
     * 启动service
     * @param context
     */
    private void startService(Context context){
        Intent voiceIntent = new Intent(context, FloatWindowService.class);
        LogUtil.d("VoiceBroacastReceiver service");
        context.startService(voiceIntent);
    }
}
